/**
 * 
 */
package com.gwcloud.leetcode.interview100;

/**
 * @ClassName   : Leetcode0125 
 * @author      : ganwei 
 * @date        : 2020年5月26日
 * @Description : Leetcode0125 验证回文串
 */
public class Leetcode0125 {
	/**
	 * -解题思路，字符串转大写再判断
	 */
    public boolean isPalindrome(String s) {
    	if(s == null){
    		return false;
    	}
    	if(s.length() == 0){
    		return true;
    	}
    	
    	StringBuilder sb = new StringBuilder();
    	for(int i = 0; i < s.length(); i++){
    		if((s.charAt(i) >= 'a' && s.charAt(i) <= 'z')||(s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')||(s.charAt(i) >= '0' && s.charAt(i) <= '9')){
    			sb.append(s.charAt(i));
    		}
    	}
    	String ss = sb.toString().toUpperCase();
    	int start = 0, end = ss.length()-1;
    	while(start <= end){
    		if(ss.charAt(start) != ss.charAt(end)){
    			return false;
    		}
    		start++;
    		end--;
    	}
    	return true;
    }
    public static void main(String[] args){
    	Leetcode0125 l0125 = new Leetcode0125();
    	System.out.println(l0125.isPalindrome("0P"));
    }
}
